﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace Slam.SharePoint
{
    /// <summary>
    /// Extension class for SPContentTypeCollection.
    /// </summary>
    public static class SPContentTypeCollectionExtender
    {
        /// <summary>
        /// SPContentTypeCollection extension method for evaluating whether a given SPContentType
        /// is contained in the SPContentTypeCollection.
        /// </summary>
        /// <param name="contentTypeCollection"></param>
        /// <param name="contentType"></param>
        /// <returns></returns>
        public static bool Contains(this SPContentTypeCollection contentTypeCollection, SPContentType contentType)
        {
            bool contains = false;
            foreach (SPContentType type in contentTypeCollection)
            {
                if (type.EqualsOrInherits(contentType))
                {
                    contains = true;
                    break;
                }
            }
            return contains;
        }
    }
}
